//
//  MLWTipsICookStepCell.m
//  KITCHEN_STORIES
//
//  Created by 孟令通 on 16/6/13.
//  Copyright © 2016年 MLW. All rights reserved.
//

#import "MLWTipsICookStepCell.h"

#import "MLWTipsICookVideoDetailModel.h"

#import "MLWTipsICookStepModel.h"

#import "MLWBaseView.h"

@implementation MLWTipsICookStepCell

-(id)initWithIdentifier:(NSString *)identifier
{
    self = [super initWithIdentifier:identifier];
    
    if (self) {
        
        self.stepArray = [NSArray array];
        
        self.identifier = identifier;
        
        
    }
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
 
}

-(void)setStepArray:(NSArray *)stepArray
{
    if (_stepArray != stepArray) {
        
        [_stepArray release];
        
        _stepArray = [stepArray retain];
        
        MLWTipsICookVideoDetailModel *model = [self.stepArray firstObject];
        
        NSInteger i = 0;
        
        CGFloat height = 0;
        
        for (MLWTipsICookStepModel *stepModel in model.stepModelArray) {
            
            UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(10, (40 + 305) * i, ScreenWidth - 10, 40)];
            
            title.text = [NSString stringWithFormat:@"%ld . %@", i + 1, stepModel.dishes_step_desc];
            [title setFont:[UIFont systemFontOfSize:14]];
            title.numberOfLines = 0;
            
            [self addSubview:title];
            [title release];
            
            UIImageView *stepImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, (40 + 5) * (i + 1) + 300 * i, ScreenWidth - 30, 300)];
            
            [stepImageView sd_setImageWithURL:[NSURL URLWithString:stepModel.dishes_step_image] placeholderImage:[UIImage imageNamed:@"placeholder"]];
            
            [self addSubview:stepImageView];
            [stepImageView release];
            
            i += 1;
        }
        
        height = (40 + 5) * (i + 1) + 300 * i + 00;
        
        
        [self getHight:height];
        
        
        
    }
}


-(void) getHight:(CGFloat)height
{
    if ([self.stepCellDelegate respondsToSelector:@selector(chengeCellHeightWithHeight:)]) {
        
        [self.stepCellDelegate chengeCellHeightWithHeight:height];
    
    }
 
}

@end
